<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>My JSP 'file_upload.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

	<SCRIPT type="text/javascript">
		function testjsdt(a){
			alert(getstr(a));
		}
		
		function getstr(a){
			return "hello,"+a;
		}
		
		function addMore(){
			var filetd = document.getElementById("filetd");
			
			var br = document.createElement("br");
			
			var fileinput = document.createElement("input");
			fileinput.type = "file";
			fileinput.name = "upload";
			
			var removebutton = document.createElement("input");
			removebutton.type= "button";
			removebutton.name= "removeb";
			removebutton.value="Remove";
			removebutton.onclick = function(){
				filetd.removeChild(br);
				filetd.removeChild(fileinput);
				filetd.removeChild(removebutton);
			}
			
			
			filetd.appendChild(br);
			filetd.appendChild(fileinput);
			filetd.appendChild(removebutton);
		}
	</SCRIPT>

	</head>

	<body>
	
		<h1 align="center">Fileupload Sample</h1>
		
		<div align="center" style="color:red">
			<s:actionerror/>
			<s:fielderror/>
		</div>
		
		<s:form action="doUpload" method="POST" enctype="multipart/form-data">
		
		<table border="1" align="center">
			<tr>
				<td align="right">Caption:</td>
				<td><input type="text" name="caption"></td>
			</tr>
			<tr>
				<td align="right">File:</td>
				<td id="filetd">
					<input type="file" name="upload">
					<input type="button" onclick="addMore()" value="Add More...">
				</td>
			</tr>
			<tr>
				<td align="right"><input type="submit" value=" Sumbit"></td>
				<td><input type="reset" value=" Reset "></td>
			</tr>
		</table>
		
		</s:form>
		
	</body>
</html>
